package com.itheima.day11.charstream.test4;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        // 创建字符输入流对象
        FileReader fr = new FileReader("myCode\\src\\com\\itheima\\day11\\b.txt");

        // 一次读取一个字符数据
        //method1(fr);

        // 一次读取多个字符数据
        char[] chars = new char[1024];
        int len;
        while ((len = fr.read(chars)) != -1) {
            System.out.print(new String(chars, 0, len));
        }

    }

    private static void method1(FileReader fr) throws IOException {
        int read;
        while ((read = fr.read()) != -1) {
            System.out.print((char) read);
        }
    }
}
